import React, {Component,} from 'react';
import {connect} from 'dva';
import {Button, InputItem, Toast} from 'antd-mobile';
import {Form, Modal,} from 'antd';
import Login from '@/components/Login';
import styles from './Login.less';
import {removeAuthorization, saveAuthorization, saveMenus, saveOrg, saveRoles, saveUser,} from '@/utils/bwdautil';
import {  decode } from '@/utils/AesUtil';

const FormItem = Form.Item;
const {Tab, UserName, Password, Mobile, Captcha, Submit, ImageVerifyCode,} = Login;



@connect(({login, loading}) => ({
  login,
}))
class ThirdLogin extends Component {
  state = {
    type: 'account',
    autoLogin: false,
    verifyCodeUuid: '',
    imageBase64: '',
    isNeedImageCode: false,
    verionData: {},
    pwdInutType: 'text',
  };



  handleSubmit = (  values) => {
    const {dispatch} = this.props;
    dispatch({
      type: 'login/thirdLogin',
      payload: values,
      callback: (res) => {
        if (res.result == "fail") {
          /*  message.success(res.msg);*/
          Modal.error({title: '跳转失败', content: res.msg});
        }
      },
    });
  };


 async componentDidMount() {
    removeAuthorization();
    let decodeStr = decodeURIComponent(this.props.match.params.userCode);
    console.error("decodeStr:" + decodeStr);

    //开始解密
    let data = await decode(decodeStr);
    console.error("data:" + data);
    let tempStr = data.split('||');
    console.error("tempStr:" + tempStr);
    if (tempStr[0] && tempStr[1]) {
      let params = {
        userCode: tempStr[0],
        callBackToken: tempStr[1],
      };
      this.handleSubmit(params);
    } else {

    }


  }

  outfiles
  render() {
    const {login, submitting,} = this.props;
    const {type, imageBase64, isNeedImageCode, verionData, pwdInutType} = this.state;
    return (
      <div className={styles.main}>

      </div>
    );
  }
}

export default ThirdLogin;
